package com.xianzw.mnfun.web.controller.front;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xianzw.mnfun.model.domain.Music;
import com.xianzw.mnfun.model.dto.JsonResult;
import com.xianzw.mnfun.model.enums.ResponseStatus;
import com.xianzw.mnfun.service.MusicService;
import com.xianzw.mnfun.web.controller.core.BaseController;

import cn.hutool.json.JSONArray;
import lombok.extern.slf4j.Slf4j;

/**
 * 音乐
 * @author xianzw
 *
 */
@Slf4j
@Controller
@RequestMapping("/music")
public class FrontMusicController extends BaseController{

    @Autowired
    private MusicService musicService;
	
    /**
     * 音乐
     * @return
     */
    @GetMapping(value = "/music")
    public String music() {
        return this.render("music/music");
    }
    
    /**
     * 获取所有歌曲
     * @return
     */
    @GetMapping("/findAll")
    @ResponseBody
    public JsonResult findAll(){
	List<Music> zplayerList = musicService.findAll();
	if (null != zplayerList && zplayerList.size() > 0) {
	      return new JsonResult(ResponseStatus.SUCCESS.getCode(), ResponseStatus.SUCCESS.getMsg(), zplayerList);
	} else {
	      return new JsonResult(ResponseStatus.EMPTY.getCode(), ResponseStatus.EMPTY.getMsg());
	}
    }
}
